<template>
    <div>
        <eagle-dialog-page2 :url="url" :params="paramArr" @initList="_initTemplateList" @open="open" @submit="submit"
            @callbackDialog="callbackDialog" @setData="setData" v-bind="$attrs" v-on="$listeners" ref="eagleDialogPage"
            :tab="true" :isPage="true" :isMulti="true" :option="option">

            <div class="check-content">
                <van-collapse v-model="activeNames" accordion>
                    <template v-for="(item, index) in list">
                        <van-collapse-item :name="index + 1">
                            <template #title>
                                <div class="checklist-title">
                                    <img class="title-logo" src="@/assets/Images/AppIcon/fragment_noticetype_3.png"
                                        alt="" />
                                    {{ item.DetailItemName }} | 共{{ item.children.length }}个项目
                                </div>
                            </template>

                            <div v-for="(innerItem, innerIndex) in item.children" :key="innerIndex">
                                <van-cell :title="innerItem.title"/>
                                  <div class="content_Choose2">
                                    <span @click="shoTemplateDeatil(innerItem)">详情</span>
                                    <span @click="hadChoose(innerItem)">选择</span>
                                  </div>
                                <van-divider />
                            </div>
                        </van-collapse-item>
                    </template>
                </van-collapse>


            </div>
        </eagle-dialog-page2>
        <van-dialog  v-model:show="show" title="详情信息" style="width: 95%;" >
            <div style="padding: 5px;">
      <div style="margin-top: 10px;"><span>依据来源:&nbsp&nbsp</span><span style="color:#8f8f8f">{{currentItem.GistSource}}</span></div>
      <div style="margin-top: 10px;"><span>整改建议:&nbsp&nbsp</span><span  style="color:#8f8f8f">{{currentItem.CorrectiveAdvise}}</span></div>
      <div style="margin-top: 10px;"><span>隐患分类:&nbsp&nbsp</span><span  style="color:#8f8f8f">{{currentItem.LGDTypeName +'>'+currentItem.LGDName}}</span></div>
      <div style="margin-top: 10px;"><span>法律责任:&nbsp&nbsp</span><span  style="color:#8f8f8f">{{currentItem.CorrectiveAdvise}}</span></div>
    </div>    
    </van-dialog>
    </div>
</template>
<script>
export default {
    name: "danger-tempalte-choose",
    props: {
        title: {
            type: String,
            default: "选择检查表",
        },
        confirmButton: {
            type: String,
            default: "完成",
        },
        tagData: {
            type: Array,
            default: () => [],
        },
    },
    data() {
        return {
            url: "/DangerCheckTaskDetail/GetDetailTemplateData",
            list: [],
            activeNames: 1,
            paramArr: [
                {
                    tCode: 'T22121600006',
                    ctCode: '',
                    CompanyCode: '',
                    page: -1,
                    limit: 10,
                }
            ],
            selectedlist: this.tagData,
            selecteData: [],
            option: { name: "Title", code: "TCode" },
            show:false,
            currentItem:''
        };
    },
    methods: {
        shoTemplateDeatil(item) {
            this.currentItem=item
            this.show=true
        },
        hadChoose(item){
            // this.$emit("callback",item);
            this.callbackDialog(item)
   
        },
        _initTemplateList(list) {
            let tempList = []
            list.map((item, index) => {
                if (item.ID === -1) {
                    item.children = []
                    list.map((item2, index2) => {
                        if (item.SEQ === item2.SEQ && item2.ID != -1) {
                            let no = index2
                            item2.title = no + '、' + item2.DetailItemName
                            item.children.push(item2)

                        }
                    })
                }
                tempList.push(item)
            })

            this.list = tempList
            this.$refs.eagleDialogPage.initSeletedData(this.selectedlist);
        },
        open(list) {
            this.list = list;
        },
        submit() {
            this.$refs.eagleDialogPage.submit();
        },
        setData(data) {
            this.selectedlist = data;

            // this.$emit("callback2",data);
        },
        callbackDialog(item) {
            this.$emit("callback",item);
        },
        deleteSelect(code) {
            this.$refs.eagleDialogPage.deleteSelect(code);
        },
    },
};
</script>
<style lang="less" scoped>
.art_content{

}
.risk_item_radio {
    width: 100%;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // border-bottom: 1px solid #e8f1f8;
}

.risk_item_buton {
    width: 100%;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.checklist-title {
    display: flex;
    align-items: center;
}
.content_Choose2{
    margin-left: 10px;
    margin-right: 10px;
    display: flex;
    justify-content: space-between;
}
</style>